Skip to content

gvfs: clear DIE_IF_CORRUPT in streaming incore fallback#873

Merged
dscho merged 1 commit intomicrosoft:vfs-2.53.0from
tyrielv:tyrielv/corrupt-object-patch
Mar 28, 2026
Merged

gvfs: clear DIE_IF_CORRUPT in streaming incore fallback#873
dscho merged 1 commit intomicrosoft:vfs-2.53.0from
tyrielv:tyrielv/corrupt-object-patch

Conversation

@tyrielv
Copy link
Copy Markdown

@tyrielv tyrielv commented Mar 27, 2026

The upstream refactoring in 4c89d31 (streaming: rely on object sources to create object stream, 2025-11-23) changed how istream_source() discovers objects. Previously, it called odb_read_object_info_extended() with flags=0 to locate the object, then tried the source-specific opener (e.g. open_istream_loose). If that failed (e.g. corrupt loose object), it fell back to open_istream_incore which re-read the object — by which time the read-object hook had already re-fetched a clean copy.

After the refactoring, istream_source() iterates over sources directly. When a corrupt loose object is found, odb_source_loose_read_object_stream fails and the loop continues to the next source. When no source has the object, it falls through to open_istream_incore, which calls odb_read_object_info_extended with OBJECT_INFO_DIE_IF_CORRUPT. This encounters the same corrupt loose file still on disk and dies before the read-object hook gets a chance to re-download a clean replacement.

Fix this by clearing OBJECT_INFO_DIE_IF_CORRUPT in open_istream_incore when GVFS_MISSING_OK is set, matching the existing pattern in odb_read_object.

This fixes the GitCorruptObjectTests functional test failures (GitRequestsReplacementForAllNullObject,
GitRequestsReplacementForObjectCorruptedWithBadData, GitRequestsReplacementForTruncatedObject) that appeared when upgrading from v2.50.1.vfs.0.1 to v2.53.0.vfs.0.0.

The upstream refactoring in 4c89d31 (streaming: rely on object
sources to create object stream, 2025-11-23) changed how
istream_source() discovers objects. Previously, it called
odb_read_object_info_extended() with flags=0 to locate the object, then
tried the source-specific opener (e.g. open_istream_loose). If that
failed (e.g. corrupt loose object), it fell back to open_istream_incore
which re-read the object — by which time the read-object hook had
already re-fetched a clean copy.

After the refactoring, istream_source() iterates over sources directly.
When a corrupt loose object is found, odb_source_loose_read_object_stream
fails and the loop continues to the next source. When no source has the
object, it falls through to open_istream_incore, which calls
odb_read_object_info_extended with OBJECT_INFO_DIE_IF_CORRUPT. This
encounters the same corrupt loose file still on disk and dies before the
read-object hook gets a chance to re-download a clean replacement.

Fix this by clearing OBJECT_INFO_DIE_IF_CORRUPT in open_istream_incore
when GVFS_MISSING_OK is set, matching the existing pattern in
odb_read_object.

This fixes the GitCorruptObjectTests functional test failures
(GitRequestsReplacementForAllNullObject,
GitRequestsReplacementForObjectCorruptedWithBadData,
GitRequestsReplacementForTruncatedObject) that appeared when upgrading
from v2.50.1.vfs.0.1 to v2.53.0.vfs.0.0.

Signed-off-by: Tyler Vella <tyvella@microsoft.com>
Copy link
Copy Markdown
Member

@dscho dscho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a companion to #782 (which predates 4c89d31, though, therefore it is not exactly an omission of that PR).

@dscho dscho merged commit b5f9211 into microsoft:vfs-2.53.0 Mar 28, 2026
66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants